package com.qingcheng.controller;

import org.springframework.security.crypto.bcrypt.BCrypt;

import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * @ProjectName: qingcheng_parent
 * @ClassName: hello
 * @Time: 2019/7/16
 * @Author: zhou24
 * @Description:
 * @Experience:
 */
public class hello {

    public static void main(String[] args) {
        //这个是盐29个字符，随机生成
        String gensalt= BCrypt.gensalt();
        System.out.println(gensalt);
        String password="123456";
        //根据盐对密码进行加密
        String hashpw=BCrypt.hashpw(password,gensalt);
        System.out.println(hashpw);
        //下面是密码校验过程
        //加密后的字符串前29位就是盐
        Boolean checkpw=BCrypt.checkpw(password,hashpw);
        System.out.println(checkpw);
        //结果：true

    }
}
